package com.edu.exam.enums;

/**
 * 成绩导出类型枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeExportType {
    /** 成绩数据 */
    GRADE("GRADE", "成绩数据"),
    /** 分析结果 */
    ANALYSIS("ANALYSIS", "分析结果"),
    /** 报告数据 */
    REPORT("REPORT", "报告数据"),
    /** 统计数据 */
    STATISTICS("STATISTICS", "统计数据"),
    /** 审计数据 */
    AUDIT("AUDIT", "审计数据"),
    /** 配置数据 */
    CONFIG("CONFIG", "配置数据"),
    /** 所有类型 */
    ALL("ALL", "所有类型"),
    /** 自定义类型 */
    CUSTOM("CUSTOM", "自定义类型");

    private final String code;
    private final String description;

    GradeExportType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeExportType fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeExportType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeExportType fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeExportType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}